﻿
<section class="content-header">
    <h1>
        日志监控
    </h1>

</section>

<section class="content">
    <div class="row">
        <div class="col-lg-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div class="dataTable-tools btn-group">
                        <button class="btn btn-primary" onclick="vm.clear();" type="button">清空</button>
                    </div>
                    @*<div class="box-tools SearchArea">
                        <div class="input-group input-group-sm" style="width: 150px; float: right;">
                            <input type="text" name="Name" class="form-control pull-right" placeholder="名称">

                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default" onclick="window.app.search();"><i class="fa fa-search"></i></button>
                            </div>
                        </div>
                    </div>*@
                </div>
                <div class="box-body no-padding">
                    <div class="table-responsive">
                        <table id="tableLog" class="table table-bordered table-striped table-condensed table-hover">
                            <thead>
                                <tr>
                                    <th>日志</th>
                                </tr>
                            </thead>
                            <tbody data-bind="foreach:logList">
                                <tr>
                                    <td data-bind="text:$data"></td>
                                </tr>
                            </tbody>
                        </table>

                    </div>

                </div>
            </div>


        </div>
    </div>
</section>

<script>


    function LogViewModel() {
        var self = this;
        self.logList = ko.observableArray();
        self.clear = function () {
            self.logList.removeAll();
        }
        self.init = function () {
            //TODO:testing;
            var serivces = new Array('http://platform.abc.com', 'http://www.abc.com', 'http://serv.abc.com/CMS');

            $.each(serivces, function (index, item) {
                var connection = $.connection;
                connection.hub.baseUrl = item;
                var log = connection.logHub;
   
                log.client.wirteLog = function (data) {
                    vm.logList.push(data);
                };

                connection.hub.start().done();
            });
           
        }
    }

    var vm = new LogViewModel();
    ko.applyBindings(vm, $("#tableLog")[0]);
    vm.init();


</script>